package cn.itcast.service.system.impl;

import cn.itcast.dao.system.FeedDao;
import cn.itcast.domain.system.FeedBack;
import cn.itcast.service.system.FeedService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class FeedServiceImpl implements FeedService {


   @Autowired
    private FeedDao feedDao;

    //新增留言
    @Override
    public void add(FeedBack feedBack) {

         feedDao.addMessage(feedBack);
    }

    //修改留言
    @Override
    public void update(FeedBack feedBack) {

        feedDao.updateMessage(feedBack);
    }

    @Override
    public List<FeedBack> findTotalMessageByCompanyId(String companyId,String email) {

        return feedDao.findTotalMessageByCompanyId(companyId,email);
    }

    @Override
    public List<FeedBack> findTotalMessageByDegree(int degree) {

        return feedDao.findTotalMessageByDegree(degree);
    }

    @Override
    public PageInfo findMySessage(String email,int page, int size) {

        PageHelper.startPage(page,size);
        List<FeedBack> list = feedDao.findMySessage(email);
        return  new PageInfo(list);

    }

    //查询留言列表
    @Override
    public PageInfo findAllByCompanyId(String email,String companyId,int page, int size) {

        PageHelper.startPage(page,size);
        List<FeedBack> list = feedDao.findAllByCompanyId(email,companyId);
        return  new PageInfo(list);
    }

    @Override
    public PageInfo findByDegree(int i,int page, int size) {

        PageHelper.startPage(page,size);
        List<FeedBack> list = feedDao.findByDegree(i);
        return  new PageInfo(list);
    }

    //根据留言id查询单个留言信息
    @Override
    public FeedBack findById(String id) {

        return  feedDao.findById(id);
    }
}
